﻿namespace IBTrader.Charts.Drawing
{
    using IBTrader.Modules.Read;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Linq;

    class ChartLine : BaseChart
    {
        public ChartLine(Worker worker, Color color) : base(worker) { this.Color = color; }
        public override void Draw(IGraphics g, Charts.Region region)
        {
            Draw(g, region, Color, Lines);
        }
        protected void Draw(IGraphics g, Charts.Region region, Color color, IEnumerable<Line> lines)
        {
            if (lines.Any())
                g.DrawLines(Pen(color), lines.Select(line => Point(region, line)).ToArray());
        }
        protected PointF Point(Charts.Region region, Line line)
        {
            return new PointF(region.x(line), region.y(line));
        }
    }
}